C Programming Codes
13.4K subscribers
139 photos
2 videos
12 links
C Programming Codes || Quizzes || DSA

Learn along with the community

Any queries
admin - @Pradeep_saii
Download Telegram
Program to convert floating point number into int.
----------------------------------------------------
Program:
#include<stdio.h>
int main()
{float a;
int b;
printf("enter floating point number:");
scanf("%f",&a);
b=(int)a;
printf("%d",b);
return 0;
}
----------------------------------------------------
#basicprograms
👍44🔥4👏3👎1
Program to check vote eligibilty if not eligible tell him/her how many years he/she should wait for eligibilty using if statement
-----------------------------------------------------
Program:
#include<stdio.h>
int main()
{ int a;
printf("Enter your age:");
scanf("%d",&a);
if(a>=18)
{
printf("Your age is %d you are eligible to vote",a);
}
if(a<18)
{ a=18-a;
printf("You should wait %dyrs for eligibilty",a);
}
return 0;
}
----------------------------------------------------
#if_statement
👍409🥰7
Program to check whether entered number is positive, negative or zero using if statement
----------------------------------------------------
Program:
#include<stdio.h>
int main ()
{ int a;
printf("Enter a number:");
scanf("%d",&a);
if(a>0)
printf("%d is a positive number",a);
if(a==0)
printf("%d is neither positive nor negative",a);
if(a<0)
printf("%d is a negative number",a);
return 0;
}
----------------------------------------------------
#if_statement
👍26
Program to check whether a number is even or odd
-----------------------------------------------------
Program:
#include<stdio.h>
int main ()
{ int a;
printf("Enter a number:");
scanf("%d",&a);
if(a%2==0)
printf("%d is an even number",a);
if(a%2!=0)
printf("%d is a odd number",a);
return 0;
}
-----------------------------------------------------
#if_statement
👍265🔥3
Program to accept three numbers and print largest among them
--------------------------------------------------
Program:
#include<stdio.h>
int main ()
{ int a,b,c;
printf("Enter three numbers:");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
printf("%d is greater than %d and %d",a,b,c);
if(b>a && b>c)
printf("%d is greater than %d and %d",b,a,c);
if(c>a && c>b)
printf("%d is greater than %d and %d",c,a,b);
return 0;
}
---------------------------------------------------
#if_statement
👍1714
Program to accept two numbers and print largest among them
------------------------------------------------
Program:
#include<stdio.h>
int main()
{ int a,b;
printf("Enter 1st number : ");
scanf("%d",&a);
printf("Enter 2nd number : ");
scanf("%d",&b);
if(a>b)
printf("%d is larger than %d",a,b);
else
printf("%d is larger than %d",b,a);
}
---------------------------------------------------
#if_else
👍224
Program to check whether a number is even or odd
--------------------------------------------------
Program:
#include<stdio.h>
int main()
{ int a;
printf("Enter a number : ");
scanf("%d",&a);
if(a%2==0)
printf("%d is an even number",a);
else
printf("%d is an odd number",a);
}
---------------------------------------------------
#if_else
👍121
Program to accept a character and if the entered character is lower case convert it into uppercase and if it is in upper case convert it into lowercase
---------------------------------------------------
Program:
#include<stdio.h>
int main()
{char ch;
printf("Enter a character:");
scanf("%c",&ch);
if(ch>='A'&&ch<='Z')
{printf("The entered character is in uppercase :%c\n",ch);
printf("The lowercase of above character is :%c",ch+32);
}
else
{printf("The entered character is in lowercase :%c\n",ch);
printf("The uppercase of above character is :%c",ch-32);
}
return 0;
}
---------------------------------------------------
#if_else
👍302
Program to check whether entered character is vowel or consonant
----------------------------------------------------
Program:
#include<stdio.h>
int main()
{char ch;
printf("Enter a character(lower case):");
scanf("%c",&ch);
if(ch=='a' ch=='e' ch=='i' ch=='o' ch=='u')
{
printf("%c is an vowel",ch);
}
else
{
printf("%c is a consonant ",ch);
}
return 0;
}
----------------------------------------------------
#if_else
friends or(||) operator is not getting printed in above text type as in image
👍40🔥43👏3🎉3👨‍💻3🤯1
Program to check whether entered year is leap year or not
----------------------------------------------------
Program:
#include<stdio.h>
int main()
{ int year;
printf("Enter ther year:");
scanf("%d",&year);
if(((year%4==0)&&(year%100!=0))||(year%400==0))
{
printf("%d is a leap year",year);
}
else
{
printf("%d is not a leap year",year);
}
return 0;
}
-------------------------------------------------------
#if_else
👍3610
Program to check whether entered number is positive, negative or zero using if else if statement
----------------------------------------------------
Program:
#include<stdio.h>
int main()
{ int num;
printf("Enter a number:");
scanf("%d",&num);
if(num>0)
{
printf("%d is a positive number",num);
}
else if(num==0)
{
printf("The entered number is equal to zero");
}
else
{
printf("%d is a negative number",num);
}
return 0;
}
----------------------------------------------------
#else_if
👍385😁2🤮1