Hello everyone, welcome to CoderGuy (A free platform to learn different programming languages). I am Ujjwal, after completing today's article you'll be able to understand various questions and its syntax in C Programming.
So Let's begin with the first question
OR
So Let's begin with the first question
Q. Write a program in C to print Hello India.
#include<stdio.h> #include<conio.h> void main() { printf("Hello India"); getch(); }
OR
#include<stdio.h> #include<conio.h> int main() { printf("Hello India"); return 0; }
10+ C Programming Questions for Beginner |
Q. Write a program in C input two numbers and print a bigger one.
#include<stdio.h> #include<conio.h> void main() { int a,b=0; clrscr(); printf("Enter first number "); scanf("%d",&a); printf("Enter Second Number "); scanf("%d",&b); If(a>b) printf("%d is bigger ",a); else printf("%d is bigger",b); getch(); }
Q. Write a program in C input two numbers and print smaller ones.
#include<stdio.h> #include<conio.h> void main() { int a,b=0; clrscr(); printf("Enter first number "); scanf("%d",&a); printf("Enter Second Number "); scanf("%d",&b); If(a<b) printf("%d is smaller ",a); else printf("%d is smaller",b); getch(); }
Q.Write a program in C input two numbers and check equal or not.
#include<stdio.h> #include<conio.h> void main() { int a,b=0; clrscr(); printf("Enter first number "); scanf("%d",&a); printf("Enter Second Number "); scanf("%d",&b); If(a==b) printf("both are equal"); else printf("Both are unequal "); getch(); }
Q. write a program in C input three numbers and find the smallest one.
#include<stdio.h> #include<conio.h> void main() { int a,b,c=0; clrscr(); printf("Enter first number "); scanf("%d",&a); printf("Enter Second Number "); scanf("%d",&b); printf("Enter Second Number "); scanf("%d",&c); If(a<b && a<c) printf("%d is smallest ",a); else if (b<c) printf("%d is smallest",b); else printf("%d is smallest ",c); getch(); }
Q. write a program in C input three numbers and find the biggest one.
#include<stdio.h> #include<conio.h> void main() { int a,b,c=0; clrscr(); printf("Enter first number "); scanf("%d",&a); printf("Enter Second Number "); scanf("%d",&b); printf("Enter Second Number "); scanf("%d",&c); If(a>b && a>c) printf("%d is biggest ",a); else if (b>c) printf("%d is biggest",b); else printf("%d is biggest ",c); getch(); }
Q.Write a program in C that input a number and check odd or even.
#include<stdio.h> #include<conio.h> void main() { int a=0; clrscr(); printf("Enter a positive number "); scanf("%d",&a); If (a%2=0) printf("%d is even number ",a); else printf("%d is odd number ",a); getch(); }
Q.Write a program in C that input a year and check leap year or not a leap year
#include<stdio.h> #include<conio.h> void main() { int a=0; clrscr(); printf("Enter a year "); scanf("%d",&a); If (a%4=0) printf("%d is leap year ",a); else printf("%d is not a leap year ",a); getch(); }
Q.Write a program in C that input a number and check positive or negative.
#include<stdio.h> #include<conio.h> void main() { int a=0; clrscr(); printf("Enter an integer "); scanf("%d",&a); If (a>0) printf("%d is a positive number",a); else printf("%d is negative number",a); getch(); }
Q. Write a program in C input a three-digit number and reverse it without using a loop.
#include<stdio.h> #include<conio.h> void main() { int a,r,rev=0; clrscr(); printf("Enter a three digit number "); scanf("%d",&a); r=a%10; rev= rev *10+ r; a=a/10; r=a%10; rev= rev *10+ r; a=a/10; r=a%10; rev=rev* 10+ r; printf("reverse=%d",rev); getch(); }
Q. Write a program in C input a three-digit number and sum its digit without using a loop.
#include<stdio.h> #include<conio.h> void main() { int a,r,rev,sum=0; clrscr(); printf("Enter a three digit number "); scanf("%d",&a); r=a%10; rev= rev *10+ r; sum=sum+rev; a=a/10; r=a%10; rev= rev *10+ r; sum=sum+rev; a=a/10; r=a%10; rev=rev* 10+ r; sum=sum+rev; printf("sum=%d",sum); getch(); }
Q.Write a program in C input a five-digit number and reverse and sum its digit without using a loop.
#include<stdio.h> #include<conio.h> void main() { int a,r,rev,sum=0; clrscr(); printf("Enter a five digit number "); scanf("%d",&a); r=a%10; rev= rev *10+ r; sum=sum+rev; a=a/10; r=a%10; rev= rev *10+ r; sum=sum+rev; a=a/10; r=a%10; rev= rev *10+ r; sum=sum+rev; a=a/10; r=a%10; rev= rev *10+ r; sum=sum+rev; a=a/10; r=a%10; rev=rev* 10+ r; sum=sum+rev; printf("reverse=%d",rev); printf("sum=%d",sum); getch(); }
Q. Write a program in C input a three and check it palindrome or not without using a loop.
#include<stdio.h>#include<conio.h>void main(){int a,r,rev,n=0;clrscr();printf("Enter a three digit number ");scanf("%d",&a);n=a;r=a%10;rev= rev *10+ r;a=a/10;r=a%10;rev= rev *10+ r;a=a/10;r=a%10;rev=rev* 10+ r;If (rev==n)printf("%d is palindrome number" ,n);elseprintf("%d is not a palindrome number",n);getch();}
Hope you enjoyed this lesson, Share this with your loved ones 💓 and help it grow. 😍
Thanks for reading
0 Comments
Enter your message here