Skip to content

Commit f1236ba

Browse files
committed
first commit
0 parents  commit f1236ba

40 files changed

+829
-0
lines changed

Diff for: Q1.c

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// program:- 1;
2+
//Write a c programe to print "Hello World"
3+
#include<stdio.h>
4+
#include<conio.h>
5+
void main()
6+
{
7+
printf("Hello World");
8+
9+
}

Diff for: Q10.c

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* program:- 10
2+
Write a c program to check whether input number is positive or negative.
3+
*/
4+
#include<stdarg.h>
5+
void main()
6+
{
7+
float n;
8+
printf("Enter the any number:- ");
9+
scanf("%f",&n);
10+
if(n>0)
11+
printf(" positive number.");
12+
else if(n<0)
13+
{
14+
printf(" negative number.");
15+
}
16+
else
17+
printf(" zero.");
18+
19+
}

Diff for: Q11.c

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* program:- 11
2+
Write a c program to check whether input number is even or odd. */
3+
#include<stdio.h>
4+
void main()
5+
{
6+
int n;
7+
printf("Enter the any integer number:- ");
8+
scanf("%d",&n);
9+
if (n%2==0)
10+
{
11+
printf("%d is a Even number",n);
12+
}
13+
else
14+
printf("%d is a Odd number",n);
15+
16+
}

Diff for: Q12.c

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* program:-12
2+
Any year is input through the keyboard. Write a c program to determine
3+
whether the year is a leap year or not.
4+
*/
5+
#include<stdio.h>
6+
void main()
7+
{
8+
int n;
9+
printf("Enter the any year:- ");
10+
scanf("%d",&n);
11+
if (n%4==0)
12+
{
13+
printf("%d is a leep year.",n);
14+
}
15+
else
16+
printf("%d is a not leep year.",n);
17+
}

Diff for: Q13.c

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* program:-13
2+
Write a c program to find maximum of two numbers.
3+
*/
4+
#include<stdio.h>
5+
void main()
6+
{
7+
int a,b;
8+
printf("Enter the two number(a&b):- ");
9+
scanf("%d%d",&a,&b);
10+
printf("\na= %d\tb= %d\n",a,b);
11+
if (a>b)
12+
{
13+
printf("a is Greater than b");
14+
}
15+
else
16+
printf("b is Greater than a");
17+
}

Diff for: Q14.c

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* printf:- 14.
2+
Write a c program to find maximum of three numbers using nested if-else.
3+
*/
4+
#include<stdio.h>
5+
void main()
6+
{
7+
int a,b,c;
8+
printf("Enter the three number:- ");
9+
scanf("%d%d%d",&a,&b,&c);
10+
printf("\na= %d\tb= %d\tc=%d\n",a,b,c);
11+
if(a>b)
12+
{
13+
if(a>c)
14+
{
15+
printf("a is Greater than b and c");
16+
}
17+
else
18+
{
19+
printf("c is Greater than a and b");
20+
}
21+
}
22+
else
23+
{
24+
if(b>a)
25+
{
26+
if(b>c)
27+
printf("b is Greater than a and c");
28+
else
29+
printf("c is Greater than a and b");
30+
}
31+
}
32+
}

Diff for: Q15.c

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* program:- 15.
2+
Any character is entered through the keyboard, write a c program to determine
3+
whether the character entered is a capital letter, a small case letter,
4+
a digit or a special symbol.
5+
*/
6+
#include<stdarg.h>
7+
void main()
8+
{
9+
char ch;
10+
printf("Enter any character:- ");
11+
scanf("%c",&ch);
12+
if ( ch>=65 && ch<=90 )
13+
{
14+
printf("%c is a capital letter",ch);
15+
}
16+
else if ( ch>=97 && ch<=122 )
17+
{
18+
printf("%c is a small case letter",ch);
19+
}
20+
else if ( ch>=48 && ch<=57 )
21+
{
22+
printf("%c is a digit",ch);
23+
}
24+
else if ( (ch>=0 && ch<=47)||( ch>=58 && ch<=64)||(ch>=91 && ch<=96)||(ch>=123 && ch<=127) )
25+
{
26+
printf("%c is a special symbol",ch);
27+
}
28+
}

Diff for: Q16.c

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* Program:- 16.
2+
Write a c program to print table of any number.
3+
*/
4+
#include<stdint.h>
5+
void main()
6+
{
7+
int n,i;
8+
printf("Enter the table of any number:- ");
9+
scanf("%d",&n);
10+
for ( i = 1; i<=10; i++)
11+
{
12+
printf("%d*%d=%d\n",n,i,(n*i));
13+
}
14+
}

Diff for: Q17.c

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* Program:- 17.
2+
Write a c program to find the factorial value of any number
3+
entered through the keyboard.
4+
*/
5+
#include<stdarg.h>
6+
void main()
7+
{
8+
int n,f=1,i;
9+
printf("Enter the any number:- ");
10+
scanf("%d",&n);
11+
for( i=n; i>=1; i--)
12+
{
13+
f=f*i;
14+
}
15+
printf("factorial value =%d",f);
16+
17+
}

Diff for: Q18.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Program:- 18.
2+
Two numbers are entered through the keyboard. Write a c program to find the
3+
value of one number raised to the power of another.
4+
*/
5+
#include<stdarg.h>
6+
void main()
7+
{
8+
int i,s=1,n,p;
9+
printf("Enter the number:- ");
10+
scanf("%d",&n);
11+
printf("Enter the power:- ");
12+
scanf("%d",&p);
13+
for(i=1; i<=p; i++)
14+
{
15+
s=s*n;
16+
}
17+
printf("sum= %d",s);
18+
}

Diff for: Q19.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Program:-19.
2+
If a number is input through the keyboard, write a c program to calculate
3+
the sum of its digits.
4+
*/
5+
#include<stdio.h>
6+
void main()
7+
{
8+
int n,r,s=0;
9+
printf("Enter the any number:- ");
10+
scanf("%d",&n);
11+
while (n>0)
12+
{
13+
r=n%10;
14+
n=n/10;
15+
s=s+r;
16+
}
17+
printf("sum of its digit =%d",s);
18+
}

Diff for: Q2.c

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* PROGRAM:-2;
2+
write a c program to add two number
3+
*/
4+
#include<stdint.h>
5+
void main()
6+
{
7+
int a=6,b=12,c;
8+
c=a+b;
9+
printf("sum=%d",c);
10+
}

Diff for: Q20.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Program:-20.
2+
If a number is input through the keyboard, write a c program to reverse the
3+
number.
4+
*/
5+
#include<stdint.h>
6+
void main()
7+
{
8+
int r,n,s=0,i;
9+
printf("Enter the any number:- ");
10+
scanf("%d",&n);
11+
while (n>0)
12+
{
13+
r=n%10;
14+
n=n/10;
15+
s=s*10+r;
16+
}
17+
printf("reverse number= %d",s);
18+
}

Diff for: Q21.c

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* Program21.
2+
Write a c program to calculate sum of first n numbers.
3+
*/
4+
#include<stdio.h>
5+
void main()
6+
{
7+
int i,n,s=0;
8+
printf("Enter the number:- ");
9+
scanf("%d",&n);
10+
for ( i=1; i<=n; i++)
11+
{
12+
s=s+i;
13+
}
14+
printf("sum of first n number= %d",s);
15+
16+
}

Diff for: Q22.c

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* Program:-22.
2+
Write a c program to calculate sum of given n numbers.
3+
*/
4+
#include<stdio.h>
5+
void main()
6+
{
7+
int i,j,n,s=0;
8+
printf("How many tarm of sum number: ");
9+
scanf("%d",&n);
10+
for(i=1;i<=n;i++)
11+
{
12+
printf("Enter the no%d: ",i);
13+
scanf("%d",&j);
14+
s=s+j;
15+
}
16+
printf("sum of all number= %d",s);
17+
}

Diff for: Q23.c

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* Program:-23.
2+
Write a c program to determine whether a number is prime or not. A prime number
3+
is one, which is divisible only by 1 or itself
4+
*/
5+
#include<stdint.h>
6+
void main()
7+
{
8+
int i,n,s,a;
9+
printf("Enter the any number:- ");
10+
scanf("%d",&n);
11+
a=n;
12+
for ( i=2; i<n; i++)
13+
{
14+
if (n%i==0)
15+
{
16+
break;
17+
}
18+
}
19+
if(a==i)
20+
{
21+
printf("%d is a prime number",a);
22+
}
23+
else
24+
printf("%d is a not prime number",a);
25+
}

Diff for: Q24.c

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* write a c programing to print out all asmstrong number between
2+
1 to 500. if sum of cubes of each digit of the number is equal
3+
to the number itself, the number is called an armstrong number.
4+
*/
5+
#include<stdio.h>
6+
void main()
7+
{
8+
int n,i,d,a;
9+
printf("\n\t------ 1 to 500 Armstrong number -------");
10+
for(i=1;i<=500;i++)
11+
{
12+
int sum=0;
13+
n=i;
14+
while(n>0)
15+
{
16+
d=n%10;
17+
n=n/10;
18+
sum=sum+(d*d*d);
19+
}
20+
if(i==sum)
21+
printf("\n %d",sum);
22+
}
23+
}

Diff for: Q25.c

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Prohram:- 25.
2+
Write a c program to determine whether a number is palindrome or not.
3+
*/
4+
#include<stdio.h>
5+
void main()
6+
{
7+
int a,b,c=0,r;
8+
printf("Enter the any number:-");
9+
scanf("%d",&a);
10+
b=a;
11+
while(a!=0)
12+
{
13+
r=a%10;
14+
c=c*10+r;
15+
a=a/10;
16+
}
17+
if(b==c)
18+
printf("%d is palindrome number",c);
19+
else
20+
printf("%d is not palindrome number",b);
21+
}

Diff for: Q26.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Program:- 26.
2+
Write a c program to find the binary equivalent of the entered number.
3+
*/
4+
#include<stdio.h>
5+
void main()
6+
{
7+
int n,s=0,d=1,a,r;
8+
printf("Enter the any Number:- ");
9+
scanf("%d",&n);
10+
while (n)
11+
{
12+
r=n%2;
13+
n=n/2;
14+
s=s+d*r;
15+
d=d*10;
16+
}
17+
printf("Binary number= %d",s);
18+
}

0 commit comments

Comments
 (0)