The C programming language is a general-purpose, operating system-agnostic, and procedural language that supports structured programming and provides low-level access to the system memory
//Q1 program for addition of numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter first value:");
scanf("%d",&a);
printf("Enter second value:");
scanf("%d",&b);
c=a+b;
printf("\nAddition is:%d",c);
getch();
}
-----------------------------------------------------------------------------------------------
//Q2 program for Subtraction of numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter first value:");
scanf("%d",&a);
printf("Enter second value:");
scanf("%d",&b);
c=a-b;
printf("\nSubtraction is:%d",c);
getch();
}
-----------------------------------------------------------------------------------------------
//Q3 program for Multiplication of numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter first value:");
scanf("%d",&a);
printf("Enter second value:");
scanf("%d",&b);
c=a*b;
printf("\nMultiplication is:%d",c);
getch();
}
------------------------------------------------------------------------------------------------
//Q4 program for Division of numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter first value:");
scanf("%d",&a);
printf("Enter second value:");
scanf("%d",&b);
c=a/b;
printf("\nDivision is:%d",c);
getch();
}
---------------------------------------------------------------------------------------------------
//Q5 program to find total no of days months and years
#include<stdio.h>
#include<conio.h>
void main()
{
int year,month,days,a,b;
printf("Enter any 3 digit no to find total no of days,months,years:");
scanf("%d",&a);
year=a/365;
printf("\nNo of Years:%d",year);
b=a%365;
month=b/30;
printf("\nNo of Months:%d",month);
days=b%30;
printf("\nNo of Days:%d",days);
getch();
}
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
STRINGS QUESTIONS IN C
//Q1 program to find length of string
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[255];
int len;
printf("Enter your name :");
scanf("%s",&str);
printf("\nYour name is:%s",str);
len=strlen(str);
printf("\nLength of string :%d ",len);
getch();
}
-----------------------------------------------------------------------------------------------------
//Q2 program to copy one string into other
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[255], str1[255];
printf("Enter your first name :");
scanf("%s",&str);
printf("\nYour first name is:%s",str);
strcpy(str1,str);
printf("\nYour full Name:%s",str1);
getch();
}
--------------------------------------------------------------------------------------------------------
//Q3 program to concatenate two strings
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[255], str1[255];
printf("Enter your first name :");
scanf("%s",&str);
printf("Enter your last name :");
scanf("%s",&str1);
strcat(str,str1);
printf("\nConcatenate of two strings:%s",str);
getch();
}
--------------------------------------------------------------------------------------------------------
//Q4 program to compare two strings
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[255], str1[255];
printf("Enter your first string :");
scanf("%s",&str);
printf("Enter your second string :");
scanf("%s",&str1);
if(strcmp(str,str1)==0)
{
printf("Both are of same strings:");
}
else
{
printf("Both are not same strings");
}
getch();
}
------------------------------------------------------------------------------------------------------------
//Q5 program to convert uppercase to lowercase
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[255];
printf("Enter your uppercase string :");
scanf("%s",&str);
strlwr(str);
printf("string in lowercase : %s",str);
getch();
}

