C Language Codes
C Language Codes
By - Samarth Guha
int main(){
int age=22 ;
printf("Age is: %d \n",age);
float pi=3.14;
printf("The value of pi is: %f \n",pi);
char star='*';
printf("Star is: %c",star);
return 0;
}
Question 3 C program to input a number from the user using the scanf function and
print it.
#include <stdio.h>
int main(){
int age;
printf("Enter age: ");
scanf("%d", &age);
printf("Age is: %d",age);
return 0;
#include <stdio.h>
int main(){
int side;//float side for floating point values
printf("Enter side: ");
scanf("%d",&side);
printf("The area of square with side given by you is: %d",side*side);
return 0;
Question 5 C language program to calculate area of circle with radius given by the user.
#include <stdio.h>
int main(){
float radius;
printf("Enter the radius: ");
scanf("%f",&radius);
printf("The area of circle with value
entered by you is: %f",3.14*radius*radius);
return 0;
Question 6 C language code to calculate the perimeter of rectangle with value of sides
given by the user.
Code: //C language code to calculate the perimeter
of rectangle with value of sides given by the
user
#include <stdio.h>
int main(){
int l,b;
printf("Enter the Length: ");
scanf("%d",&l);
printf("Enter the breadth: ");
scanf("%d",&b);
printf("The perimeter of rectangle with
values given by you is: %d",2*(l+b));
return 0;
Question 7 C Language program to input 2 numbers from the user and print their sum.
Code: //C Language program to input 2 numbers
from the user and print their sum
#include <stdio.h>
int main(){
int a; //can also be written commonly as int
a,b;
printf("Enter the first number: ");
scanf("%d",&a);
int b;
printf("Enter the second number: ");
scanf("%d",&b);
#include <stdio.h>
int main(){
float radius;
printf("Enter the radius: ");
scanf("%f",&radius);
printf("The area of circle with value
entered by you is: %f",3.14*radius*radius);
return 0;
#include <stdio.h>
int main(){
int isSunday = 1;
int isSnowing = 1;
printf("The answer is: %d",isSunday &&
isSnowing);
int isMonday = 1;
int isRaining = 0;
printf("The answer is: %d",isMonday ||
isRaining);
return 0;
Code: //C language program to check whether the number entered by the user is in the
range 9 - 100
//C language program to check whether the number entered by the user is a two
digit number of not
#include <stdio.h>
int main(){
int x;
printf("Enter a number: ");
scanf("%d",& x);
printf("The number entered by you is in between 9 to 100: %d",x>9 &&
x<=100);//1 for true and 0 for false
return 0;
#include <stdio.h>
int main(){
int a;
printf("Enter the first number: ");
scanf("%d",& a);
int b;
printf("Enter the second number: ");
scanf("%d",& b);
int c;
printf("Enter the third number: ");
scanf("%d",& c);
int d = a+b+c/3;
printf("The average of three numbers is:
%d",d);
return 0;
#include <stdio.h>
int main(){
//even -> 1
//odd -> 0
int n;
printf("Enter a number: ");
scanf("%d",& n);
printf("The number entered by you is:
%d",n%2 == 0);
return 0;
int main(){
int age=22 ;
printf("Age is: %d \n",age);
float pi=3.14;
printf("The value of pi is: %f \n",pi);
char star='*';
printf("Star is: %c",star);
return 0;
}
int main(){
int age=22 ;
printf("Age is: %d \n",age);
float pi=3.14;
printf("The value of pi is: %f \n",pi);
char star='*';
printf("Star is: %c",star);
return 0;
}
int main(){
int age=22 ;
printf("Age is: %d \n",age);
float pi=3.14;
printf("The value of pi is: %f \n",pi);
char star='*';
printf("Star is: %c",star);
return 0;
}