- Write a program to display value of a+b, if a=5, b=2, in C language.
#include <stdio.h>int main(){int a = 5;int b = 2;int sum = a+b;printf(" a+b= %d", sum);return 0;}

- Write a program If a=4 then find the value of a2 in C language.
#include <stdio.h>int main() { int a = 4; int squared = a * a; printf("The square of 4 is %d\n", squared); return 0;}

- Write a program take one integer from user and find cube value in C language.
#include <stdio.h>int main() { int x; printf("Enter an Integer: "); scanf("%d", &x); int cube = x * x * x; printf("The cube of %d is %d\n", x, cube); return 0;}

- Write a program If a=100 then find the square root of ‘a’ in C language.
#include<stdio.h>#include<math.h>int main(){ double a = 100; printf("\n The square root of %lf is %lf,", a, sqrt(a)); return 0;}
here if code did not compile then you need to put as
$gcc fun.c -lm

- Write a program If a=5, b=6 then find the value of a 2 +b 2 in C language.
#include <stdio.h>int main() { int a = 5; int b = 6; int result = a*a + b*b; printf("The value of given expression is: %d", result); return 0;}

- Write a program take 1 integer from user and check it is positive and negative in C language.
#include <stdio.h>int main() { int a; printf("Enter an integer: "); scanf("%d", &a); if(a>0) { printf("%d It is positive number", a);} else { printf("%d It is negative number", a); } return 0;}

- Write a program take 1 integer from user and check it is multiple of 5 or not in C language.
#include<stdio.h>int main(){ int a; printf("Enter an integer: "); scanf("%d", &a); if(a % 5 == 0) { printf("%d is multiple of 5", a); } else { printf("%d is not multiple of 5", a); } return 0;}

- If a five-digit number is input through the keyboard, write a program to calculate the sum of its. digit.
#include<stdio.h>int main(){int num, sum=0;printf("Enter five number:");scanf("%d",&num);
sum+=(num/10000)%10;sum+=(num/1000)%10;sum+=(num/100)%10;sum+=(num/10)%10;sum+=num%10;
printf("Sum of each digit is %d",sum);
return 0;}

- If a five digit number is input through the keyboard, write program to reverse the number.
#include<stdio.h>int main(){int num, sum=0;printf("Enter five number:");scanf("%d",&num);
printf("Sum of each digit is %d%d%d%d%d",num%10,(num/10)%10,(num/100)%10,(num/1000)%10,(num/10000)%10);
return 0;}

- If length of three side of triangle are input through the keyboard, write a program to find the area of the triangle.
#include<stdio.h>#include<math.h>int main(){float a,b,c,semiperimeter,area,s;
printf("Enter 3 side of number:\n");scanf("%f%f%f",&a,&b,&c);
semiperimeter=(a+b+c)/2;s=semiperimeter;
area=sqrt(s*((s-a)*(s-b)*(s-c)))*1.1;
printf("total area is %f",area);
return 0;}

#include <stdio.h>
int main()
{
int a = 5;
int b = 2;
int sum = a+b;
printf(" a+b= %d", sum);
return 0;
}

#include <stdio.h>
int main()
{
int a = 4;
int squared = a * a;
printf("The square of 4 is %d\n", squared);
return 0;
}

#include <stdio.h>
int main()
{
int x;
printf("Enter an Integer: ");
scanf("%d", &x);
int cube = x * x * x;
printf("The cube of %d is %d\n", x, cube);
return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{
double a = 100;
printf("\n The square root of %lf is %lf,", a, sqrt(a));
return 0;
}
here if code did not compile then you need to put as
$gcc fun.c -lm

#include <stdio.h>
int main()
{
int a = 5;
int b = 6;
int result = a*a + b*b;
printf("The value of given expression is: %d", result);
return 0;
}

#include <stdio.h>
int main()
{
int a;
printf("Enter an integer: ");
scanf("%d", &a);
if(a>0)
{
printf("%d It is positive number", a);
}
else
{
printf("%d It is negative number", a);
}
return 0;
}

#include<stdio.h>
int main()
{
int a;
printf("Enter an integer: ");
scanf("%d", &a);
if(a % 5 == 0)
{
printf("%d is multiple of 5", a);
}
else
{
printf("%d is not multiple of 5", a);
}
return 0;
}

#include<stdio.h>
int main(){
int num, sum=0;
printf("Enter five number:");
scanf("%d",&num);
sum+=(num/10000)%10;
sum+=(num/1000)%10;
sum+=(num/100)%10;
sum+=(num/10)%10;
sum+=num%10;
printf("Sum of each digit is %d",sum);
return 0;
}

#include<stdio.h>
int main(){
int num, sum=0;
printf("Enter five number:");
scanf("%d",&num);
printf("Sum of each digit is %d%d%d%d%d",
num%10,
(num/10)%10,
(num/100)%10,
(num/1000)%10,
(num/10000)%10
);
return 0;
}

#include<stdio.h>
#include<math.h>
int main(){
float a,b,c,semiperimeter,area,s;
printf("Enter 3 side of number:\n");
scanf("%f%f%f",&a,&b,&c);
semiperimeter=(a+b+c)/2;
s=semiperimeter;
area=sqrt(s*((s-a)*(s-b)*(s-c)))*1.1;
printf("total area is %f",area);
return 0;
}

0 Comments had been done yet:
Post a Comment