Skip to content
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# C-basicprograms
This repo contains basics programs in c programming language
## This repo contains basics programs in c programming language.
| Program No.| Question |
| ------- | ------ |
| Program-01 | Program to print pattern |
| Program-02 | Program to check whether the given number is prime or not |
| Program-03 | Program to find largest of three number using simple if condition |
| Program-04 | Program to find largest of three number using if-else condition |
| Program-05 | Program to find largest of three number using nested if condition |
| Program-06 | Program to find largest of three number using ternary operator |
| Program-07 | Program to check whether the given year is leap or not |
| Program-08 | Program to convert number into year, months and days |
| Program-09 | Program to check two number are equal without logical operator |
| Program-10 | Program to find square and half of given number without using built-in function and arithmetic operator|
| Program-11 | Program on arithmetic operators |
| Program-12 | Program on relational operators |
| Program-13 | Program on bit-wise operator. |
| Program-14 | Program on increment and decrement operator. |
| Program-15 | Program to find sum of digits between given range which are divisible by 3 |
| Program-16 | Program to check whether the given number is neon or not |
| Program-17 | Program to check whether the given number is prefect or not |
| Program-18 | Program to check given number is Armstrong or not |
| Program-19 | Program to find power of a given number |
| Program-20 | Program to convert datatype explicitly |
| Program-21 | Program to check whether the given number is prime or not |
| Program-22 | Program to find GCD and LCM of given two number |
| Program-23 | Program to find number of digits in a given number |
| Program-24 | Program to print the pattern |
| Program-25 | Program to print the pattern |
| Program-26 | Program to print the pattern |
| Program-27 | Program to print the pattern |
| Program-28 | Program to print the pattern |
| Program-29 | Program to print the pattern |
| Program-30 | Program to print the pattern |
| Program-31 | Program to take the details of student and print the details of students using array and to add details of new students into the existing array |
| Program-32 | Program to take the details of student and print the details |
24 changes: 18 additions & 6 deletions program-20/program.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#include<stdio.h>
void main()
{
if(printf("hello world\n"))
{
#include <stdio.h>
#include <stdlib.h>

}
int main()
{ int a=7,b=2;
// printf("enter two number !\n");
//scanf("%d%d",&a,&b);
printf("%d",a/b);

printf("%d\n",(float)a/b);
printf("%d\n",(float)a/(float)b);
printf("%d\n",a/(float)b);

printf("%f\n",a/b);
printf("%f\n",(float)(a/b));
printf("%f\n",(float) a/b);
printf("%f\n",(float)a/(float)b);
printf("%f\n",a/(float)b);
return 0;
}
Binary file added program-31/a.out
Binary file not shown.
12 changes: 6 additions & 6 deletions program-31/program.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ int main()
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter the details of student-%d\n",i);
printf("Enter the details of student - %d\n",i);
printf("Enter the name of the student\n");
scanf("%s",&stud[i].n);
printf("Enter USN\n");
scanf("%s",&stud[i].u);
printf("Enter total marks\n");
scanf("%d",&stud[i].m);
}
printf("|\tSl.no\t|\tName\t|\tUSN\t\t|\tMark\t|\n");
printf("|\tSl.no\t|\tName\t\t|\tUSN\t\t|\tMark\t|\n");
for(i=1;i<=n;i++)
{
printf("|\t%d\t|\t%s\t|\t%s\t|\t%d\t|\n",i,stud[i].n,stud[i].u,stud[i].m);
printf("|\t%d\t|\t%-10s\t|\t%s\t|\t%d\t|\n",i,stud[i].n,stud[i].u,stud[i].m);
}
printf("Enter the details of new student\n");
printf("Enter the name\n");
printf("Enter the name\n"); //preferred to enter equal length of name
scanf("%s",&stud2.n);
printf("Enter the USN\n");
scanf("%s",&stud2.u);
Expand All @@ -40,10 +40,10 @@ int main()
stud[i+1]=stud[i];
}
stud[p]=stud2;
printf("|\tSl.no\t|\tName\t|\tUSN\t\t |\tMark\t|\n");
printf("|\tSl.no\t|\tName\t\t|\tUSN\t\t |\tMark\t|\n");
for(i=1;i<=n+1;i++)
{
printf("|\t%d\t|\t%s\t|\t%s\t|\t%d\t|\n",i,stud[i].n,stud[i].u,stud[i].m);
printf("|\t%d\t|\t%-10s\t|\t%s\t|\t%d\t|\n",i,stud[i].n,stud[i].u,stud[i].m);

}

Expand Down
29 changes: 29 additions & 0 deletions program-32/program.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdio.h>
struct student
{
char n[100];
char u[100];
int m;
}stud[10],stud2;
int main()
{
int n,i,p=0;
printf("Enter the number of student\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter the details of student - %d\n",i);
printf("Enter the name of the student\n");
scanf("%s",&stud[i].n);
printf("Enter USN\n");
scanf("%s",&stud[i].u);
printf("Enter total marks\n");
scanf("%d",&stud[i].m);
}
printf("|\tSl.no\t|\tName\t\t|\tUSN\t\t|\tMark\t|\n");
for(i=1;i<=n;i++)
{
printf("|\t%d\t|\t%-10s\t|\t%s\t|\t%d\t|\n",i,stud[i].n,stud[i].u,stud[i].m);
}
return 0;
}