SlideShare a Scribd company logo
C Programming Example
Question:-
Write a program that represents
Switch case, also add function in
each case.
#include<stdio.h>
int result;
int add(int a, int b);
int subtract(int a, int b);
int multi(int a, int b);
int main() {
int x, y, choice;
printf("tEnter two number: ");
scanf("%d%d", &x, &y);
printf("n");
printf("tAddition. [1]n");
printf("tSubtraction .[2]n");
printf("tMultiplication.[3]nn");
switch(choice) {
case 1:
printf("tTotal is %dn", add(x, y)); break;
case 2: printf("tSubtraction is %dn", subtract(x, y));
break;
case 3:
printf("tMultiplication is %dn", multi(x, y));
break;
default:
printf("tYou entered wrong number!!n");
break; } }
int add(int a, int b) { result = a + b; return result; }
int subtract(int a, int b) { result = a - b; return result; }
int multi(int a, int b) { result = a * b; return result; }
Addition
Subtraction
Multiplication
Question:-
C Program to check Whether a Number is Prime or Not?
Output
This program takes a positive integer
from user and stores it in variable n.Then,
for loop is executed which checks whether
the number entered by user is perfectly
divisible by i or not starting with initial
value of i equals to 2 and increasing the
value of i in each iteration.
If the number entered by user is perfectly
divisible by i then, flag is set to 1
and that number will not be a prime
number but, if the number is not perfectly
divisible by i until test condition i<=n/2 is
true means,
it is only divisible by 1 and that number
itself and that number is a prime number.
Code description:
#include <stdio.h>
int main()
{
double divi = 1, h = 0, sum = 0;
double str[100];
int i = 0, j = 0, r, value;
printf("Division multiple
integers.nnn");
printf("Enter the number of value = ");
scanf("%d", &value);
printf("nn");
Question:-
How to divide multiple
integers
Code:
for (j = 0; j < 1; j++){
printf("enter %d%s value = ", j + 1, (j + 1 == 1) ? "st": (j + 1 == 2) ?
"nd": (j + 1 == 3) ? "rd": " ");
scanf("%lf", &str[j]);
divi = str[j] / divi;
printf("%.2lfn", divi); }
for (i = 1; i < value; i++){
printf("enter %d%s value = ", i + 1, (i + 1 == 1) ? "st": (i + 1 == 2) ?
"nd": (i + 1 == 3) ? "rd": "th");
scanf("%lf", &str[i]);
divi = divi / str[i];
printf("%lfn", divi);}
getch();return 0;}
At first I use “stdio” header file, I use
double data type and integer data type.
now firstly the program want the number
of value from the user that can be 5, 6, 7
and even more now the first for loop will
get the first value from the user then the
program put the value into "divi" that's
because it can divide with the next value.
Now the second "for" loop will get the
second value from user from the user and
divide from the first value then the
program do the same thing till the number
of value that is given by the user. and al last
it will show the result to the user. then
terminated.
Code Description:
C Programming Example
#include <stdio.h>
int main(){
int qsn1, qsn2, qsn3, qsn4, qsn5, qsn6;
printf ("1. What is the capital of Bangladesh?nn1.
Dhakan2. Chittagongn3. Khulna");
printf("nEnter answer : ");
scanf("%d", &qsn1);
printf ("2. What is the best mobile company?nn1.
Symphonyn2. Blackberryn3. Apple");
printf("nEnter answer : ");
scanf("%d", &qsn2);
printf ("3. Where is Bangladesh situated?nn1. Asian2.
African3. America");
printf("nEnter answer : ");
scanf("%d", &qsn3);
printf ("4. What is the capital of England?nn1.
Dhakan2. Londonn3. Khulna");
printf("nEnter answer : ");
scanf("%d", &qsn4);
Question:-
A program that can check the
given MCQ’s from the user.
printf (“5. What is the capital of Japan?nn1. Dhakan2.
Londonn3. Tokyo");
printf("nEnter answer : ");
scanf("%d", &qsn5);
printf("nn");
if (qsn1 == 1){
printf("1. Truen");
}else if (qsn1 == 3 || qsn1 == 2){
printf("1. Falsen");
}
if (qsn2 == 3){
printf("2. Truen");
}else if (qsn2 == 1 || qsn2 == 2){
printf("2. False.n");
}
if (qsn3 == 1){
printf("3. Truen");
}else if (qsn3 == 3 || qsn3 == 2){
printf("3. False.n");
}
if (qsn4 == 2){
printf("4. Truen");
}else if (qsn4 == 1 || qsn4 == 3){
printf("4. False.n");
}
if (qsn5 == 3){
printf("5. Truen");
}else if (qsn5 == 1 || qsn5 == 2){
printf("5. False.n");
}
return 0;
}
Output
Output
Ad

More Related Content

What's hot (20)

C programs
C programsC programs
C programs
Minu S
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
Dr. Loganathan R
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
Prasadu Peddi
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
Hazrat Bilal
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
Dr. Loganathan R
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
Leandro Schenone
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
Dr. Loganathan R
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
Dr. Loganathan R
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
vrgokila
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
Mansi Tyagi
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
Dr. Loganathan R
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
Abdullah Al Naser
 
Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.
Hazrat Bilal
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
Dr. Loganathan R
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
RAJWANT KAUR
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
Dr. Loganathan R
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
Tony Kurishingal
 
week-1x
week-1xweek-1x
week-1x
KITE www.kitecolleges.com
 
C programs
C programsC programs
C programs
Minu S
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
Dr. Loganathan R
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
Prasadu Peddi
 
Let us C (by yashvant Kanetkar) chapter 3 Solution
Let us C   (by yashvant Kanetkar) chapter 3 SolutionLet us C   (by yashvant Kanetkar) chapter 3 Solution
Let us C (by yashvant Kanetkar) chapter 3 Solution
Hazrat Bilal
 
Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1Bcsl 033 data and file structures lab s2-1
Bcsl 033 data and file structures lab s2-1
Dr. Loganathan R
 
Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3Bcsl 033 data and file structures lab s2-3
Bcsl 033 data and file structures lab s2-3
Dr. Loganathan R
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3Bcsl 033 data and file structures lab s1-3
Bcsl 033 data and file structures lab s1-3
Dr. Loganathan R
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
vrgokila
 
C Language Programs
C Language Programs C Language Programs
C Language Programs
Mansi Tyagi
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
Dr. Loganathan R
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
Abdullah Al Naser
 
Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.
Hazrat Bilal
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
Dr. Loganathan R
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
RAJWANT KAUR
 
Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3Bcsl 033 data and file structures lab s3-3
Bcsl 033 data and file structures lab s3-3
Dr. Loganathan R
 

Viewers also liked (19)

INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
Mohit Saini
 
Pengaturcaraan C
Pengaturcaraan CPengaturcaraan C
Pengaturcaraan C
cyberns_
 
Cara kerja input/proses/output, flowchart, pseudo
Cara kerja input/proses/output, flowchart, pseudoCara kerja input/proses/output, flowchart, pseudo
Cara kerja input/proses/output, flowchart, pseudo
Farid Diah
 
Assignments 150507052746-lva1-app6891
Assignments 150507052746-lva1-app6891Assignments 150507052746-lva1-app6891
Assignments 150507052746-lva1-app6891
Mohit Saini
 
Pengaturcaraan asas
Pengaturcaraan asasPengaturcaraan asas
Pengaturcaraan asas
Unit Kediaman Luar Kampus
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
MOHAMAD NOH AHMAD
 
Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)
mujeeb memon
 
4.0 projek pengaturcaraan
4.0 projek pengaturcaraan4.0 projek pengaturcaraan
4.0 projek pengaturcaraan
Sakinah Hassan
 
1.0 pengaturcaraan
1.0 pengaturcaraan1.0 pengaturcaraan
1.0 pengaturcaraan
Sakinah Hassan
 
1.0 memahami pengaturcaraan
1.0 memahami pengaturcaraan1.0 memahami pengaturcaraan
1.0 memahami pengaturcaraan
Botol Budu
 
Pengenalan kepada pengaturcaraan komputer
Pengenalan kepada pengaturcaraan komputerPengenalan kepada pengaturcaraan komputer
Pengenalan kepada pengaturcaraan komputer
ctlady92
 
Pengaturcaraan c
Pengaturcaraan cPengaturcaraan c
Pengaturcaraan c
Hakim Abdul Rahman
 
5.1 konsep asas pengaturcaraan
5.1 konsep asas pengaturcaraan5.1 konsep asas pengaturcaraan
5.1 konsep asas pengaturcaraan
dean36
 
C notes.pdf
C notes.pdfC notes.pdf
C notes.pdf
Durga Padma
 
C ppt
C pptC ppt
C ppt
jasmeen kr
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
Amr Ali (ISTQB CTAL Full, CSM, ITIL Foundation)
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
JavaTpoint.Com
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
Basics of C programming
Basics of C programmingBasics of C programming
Basics of C programming
avikdhupar
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
Mohit Saini
 
Pengaturcaraan C
Pengaturcaraan CPengaturcaraan C
Pengaturcaraan C
cyberns_
 
Cara kerja input/proses/output, flowchart, pseudo
Cara kerja input/proses/output, flowchart, pseudoCara kerja input/proses/output, flowchart, pseudo
Cara kerja input/proses/output, flowchart, pseudo
Farid Diah
 
Assignments 150507052746-lva1-app6891
Assignments 150507052746-lva1-app6891Assignments 150507052746-lva1-app6891
Assignments 150507052746-lva1-app6891
Mohit Saini
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
MOHAMAD NOH AHMAD
 
Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)Introduction to the c programming language (amazing and easy book for beginners)
Introduction to the c programming language (amazing and easy book for beginners)
mujeeb memon
 
4.0 projek pengaturcaraan
4.0 projek pengaturcaraan4.0 projek pengaturcaraan
4.0 projek pengaturcaraan
Sakinah Hassan
 
1.0 memahami pengaturcaraan
1.0 memahami pengaturcaraan1.0 memahami pengaturcaraan
1.0 memahami pengaturcaraan
Botol Budu
 
Pengenalan kepada pengaturcaraan komputer
Pengenalan kepada pengaturcaraan komputerPengenalan kepada pengaturcaraan komputer
Pengenalan kepada pengaturcaraan komputer
ctlady92
 
5.1 konsep asas pengaturcaraan
5.1 konsep asas pengaturcaraan5.1 konsep asas pengaturcaraan
5.1 konsep asas pengaturcaraan
dean36
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
JavaTpoint.Com
 
Ad

Similar to C Programming Example (20)

C programs
C programsC programs
C programs
Vikram Nandini
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
manoj11manu
 
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Salar Delavar Qashqai
 
7 functions
7  functions7  functions
7 functions
MomenMostafa
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
Bilal Mirza
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
tristans3
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
Sowri Rajan
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
Vishal Singh
 
Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7
alish sha
 
C programming codes for the class assignment
C programming codes for the class assignmentC programming codes for the class assignment
C programming codes for the class assignment
Zenith SVG
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
Rahul Pandit
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
DR B.Surendiran .
 
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU HyderabadSrinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu
 
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH HyderabadSrinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
C lab programs
C lab programsC lab programs
C lab programs
Dr. Prashant Vats
 
C lab
C labC lab
C lab
rajni kaushal
 
C-programs
C-programsC-programs
C-programs
SSGMCE SHEGAON
 
1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf
sutharbharat59
 
Fucntions & Pointers in C
Fucntions & Pointers in CFucntions & Pointers in C
Fucntions & Pointers in C
Janani Satheshkumar
 
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Salar Delavar Qashqai
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
Bilal Mirza
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
tristans3
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
Sowri Rajan
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
Vishal Singh
 
Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7Dam31303 dti2143 lab sheet 7
Dam31303 dti2143 lab sheet 7
alish sha
 
C programming codes for the class assignment
C programming codes for the class assignmentC programming codes for the class assignment
C programming codes for the class assignment
Zenith SVG
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
Rahul Pandit
 
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
Computer programming subject notes. Quick easy notes for C Programming.Cheat ...
DR B.Surendiran .
 
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU HyderabadSrinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu
 
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH HyderabadSrinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu
 
1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf
sutharbharat59
 
Ad

More from University of Potsdam (20)

Computer fundamentals 01
Computer fundamentals 01Computer fundamentals 01
Computer fundamentals 01
University of Potsdam
 
Workshop on android apps development
Workshop on android apps developmentWorkshop on android apps development
Workshop on android apps development
University of Potsdam
 
Transparency and concurrency
Transparency and concurrencyTransparency and concurrency
Transparency and concurrency
University of Potsdam
 
Database System Architecture
Database System ArchitectureDatabase System Architecture
Database System Architecture
University of Potsdam
 
Functional dependency and normalization
Functional dependency and normalizationFunctional dependency and normalization
Functional dependency and normalization
University of Potsdam
 
indexing and hashing
indexing and hashingindexing and hashing
indexing and hashing
University of Potsdam
 
data recovery-raid
data recovery-raiddata recovery-raid
data recovery-raid
University of Potsdam
 
Query processing
Query processingQuery processing
Query processing
University of Potsdam
 
Machine Learning for Data Mining
Machine Learning for Data MiningMachine Learning for Data Mining
Machine Learning for Data Mining
University of Potsdam
 
Tree, function and graph
Tree, function and graphTree, function and graph
Tree, function and graph
University of Potsdam
 
Sonet
SonetSonet
Sonet
University of Potsdam
 
Sets in discrete mathematics
Sets in discrete mathematicsSets in discrete mathematics
Sets in discrete mathematics
University of Potsdam
 
Set in discrete mathematics
Set in discrete mathematicsSet in discrete mathematics
Set in discrete mathematics
University of Potsdam
 
Series parallel ac rlc networks
Series parallel ac rlc networksSeries parallel ac rlc networks
Series parallel ac rlc networks
University of Potsdam
 
Series parallel ac networks
Series parallel ac networksSeries parallel ac networks
Series parallel ac networks
University of Potsdam
 
Relations
RelationsRelations
Relations
University of Potsdam
 
Relations
RelationsRelations
Relations
University of Potsdam
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
University of Potsdam
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
University of Potsdam
 
Prim algorithm
Prim algorithmPrim algorithm
Prim algorithm
University of Potsdam
 

Recently uploaded (20)

APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
Debunking the Myths behind AI - v1, Carl Dalby
Debunking the Myths behind AI -  v1, Carl DalbyDebunking the Myths behind AI -  v1, Carl Dalby
Debunking the Myths behind AI - v1, Carl Dalby
Association for Project Management
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)
GS Virdi
 
How to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo SlidesHow to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo Slides
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdfRanking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Rafael Villas B
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.
MCH
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
Lecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptxLecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptx
Arshad Shaikh
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE  BY sweety Tamanna Mahapatra MSc PediatricAPGAR SCORE  BY sweety Tamanna Mahapatra MSc Pediatric
APGAR SCORE BY sweety Tamanna Mahapatra MSc Pediatric
SweetytamannaMohapat
 
Herbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptxHerbs Used in Cosmetic Formulations .pptx
Herbs Used in Cosmetic Formulations .pptx
RAJU THENGE
 
dynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south Indiadynastic art of the Pallava dynasty south India
dynastic art of the Pallava dynasty south India
PrachiSontakke5
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)What is the Philosophy of Statistics? (and how I was drawn to it)
What is the Philosophy of Statistics? (and how I was drawn to it)
jemille6
 
Kenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 CohortKenan Fellows Participants, Projects 2025-26 Cohort
Kenan Fellows Participants, Projects 2025-26 Cohort
EducationNC
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)Junction Field Effect Transistors (JFET)
Junction Field Effect Transistors (JFET)
GS Virdi
 
How to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo SlidesHow to Add Customer Note in Odoo 18 POS - Odoo Slides
How to Add Customer Note in Odoo 18 POS - Odoo Slides
Celine George
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18How to Manage Purchase Alternatives in Odoo 18
How to Manage Purchase Alternatives in Odoo 18
Celine George
 
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdfRanking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Ranking_Felicidade_2024_com_Educacao_Marketing Educacional_V2.pdf
Rafael Villas B
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.03#UNTAGGED. Generosity in architecture.
03#UNTAGGED. Generosity in architecture.
MCH
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Grade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable WorksheetGrade 2 - Mathematics - Printable Worksheet
Grade 2 - Mathematics - Printable Worksheet
Sritoma Majumder
 
Lecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptxLecture 1 Introduction history and institutes of entomology_1.pptx
Lecture 1 Introduction history and institutes of entomology_1.pptx
Arshad Shaikh
 
How to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo SlidesHow to Create Kanban View in Odoo 18 - Odoo Slides
How to Create Kanban View in Odoo 18 - Odoo Slides
Celine George
 

C Programming Example

  • 2. Question:- Write a program that represents Switch case, also add function in each case. #include<stdio.h> int result; int add(int a, int b); int subtract(int a, int b); int multi(int a, int b); int main() { int x, y, choice; printf("tEnter two number: "); scanf("%d%d", &x, &y); printf("n"); printf("tAddition. [1]n"); printf("tSubtraction .[2]n"); printf("tMultiplication.[3]nn");
  • 3. switch(choice) { case 1: printf("tTotal is %dn", add(x, y)); break; case 2: printf("tSubtraction is %dn", subtract(x, y)); break; case 3: printf("tMultiplication is %dn", multi(x, y)); break; default: printf("tYou entered wrong number!!n"); break; } } int add(int a, int b) { result = a + b; return result; } int subtract(int a, int b) { result = a - b; return result; } int multi(int a, int b) { result = a * b; return result; }
  • 5. Question:- C Program to check Whether a Number is Prime or Not?
  • 7. This program takes a positive integer from user and stores it in variable n.Then, for loop is executed which checks whether the number entered by user is perfectly divisible by i or not starting with initial value of i equals to 2 and increasing the value of i in each iteration. If the number entered by user is perfectly divisible by i then, flag is set to 1 and that number will not be a prime number but, if the number is not perfectly divisible by i until test condition i<=n/2 is true means, it is only divisible by 1 and that number itself and that number is a prime number. Code description:
  • 8. #include <stdio.h> int main() { double divi = 1, h = 0, sum = 0; double str[100]; int i = 0, j = 0, r, value; printf("Division multiple integers.nnn"); printf("Enter the number of value = "); scanf("%d", &value); printf("nn"); Question:- How to divide multiple integers Code:
  • 9. for (j = 0; j < 1; j++){ printf("enter %d%s value = ", j + 1, (j + 1 == 1) ? "st": (j + 1 == 2) ? "nd": (j + 1 == 3) ? "rd": " "); scanf("%lf", &str[j]); divi = str[j] / divi; printf("%.2lfn", divi); } for (i = 1; i < value; i++){ printf("enter %d%s value = ", i + 1, (i + 1 == 1) ? "st": (i + 1 == 2) ? "nd": (i + 1 == 3) ? "rd": "th"); scanf("%lf", &str[i]); divi = divi / str[i]; printf("%lfn", divi);} getch();return 0;}
  • 10. At first I use “stdio” header file, I use double data type and integer data type. now firstly the program want the number of value from the user that can be 5, 6, 7 and even more now the first for loop will get the first value from the user then the program put the value into "divi" that's because it can divide with the next value. Now the second "for" loop will get the second value from user from the user and divide from the first value then the program do the same thing till the number of value that is given by the user. and al last it will show the result to the user. then terminated. Code Description:
  • 12. #include <stdio.h> int main(){ int qsn1, qsn2, qsn3, qsn4, qsn5, qsn6; printf ("1. What is the capital of Bangladesh?nn1. Dhakan2. Chittagongn3. Khulna"); printf("nEnter answer : "); scanf("%d", &qsn1); printf ("2. What is the best mobile company?nn1. Symphonyn2. Blackberryn3. Apple"); printf("nEnter answer : "); scanf("%d", &qsn2); printf ("3. Where is Bangladesh situated?nn1. Asian2. African3. America"); printf("nEnter answer : "); scanf("%d", &qsn3); printf ("4. What is the capital of England?nn1. Dhakan2. Londonn3. Khulna"); printf("nEnter answer : "); scanf("%d", &qsn4); Question:- A program that can check the given MCQ’s from the user.
  • 13. printf (“5. What is the capital of Japan?nn1. Dhakan2. Londonn3. Tokyo"); printf("nEnter answer : "); scanf("%d", &qsn5); printf("nn"); if (qsn1 == 1){ printf("1. Truen"); }else if (qsn1 == 3 || qsn1 == 2){ printf("1. Falsen"); } if (qsn2 == 3){ printf("2. Truen"); }else if (qsn2 == 1 || qsn2 == 2){ printf("2. False.n"); } if (qsn3 == 1){ printf("3. Truen"); }else if (qsn3 == 3 || qsn3 == 2){ printf("3. False.n"); }
  • 14. if (qsn4 == 2){ printf("4. Truen"); }else if (qsn4 == 1 || qsn4 == 3){ printf("4. False.n"); } if (qsn5 == 3){ printf("5. Truen"); }else if (qsn5 == 1 || qsn5 == 2){ printf("5. False.n"); } return 0; } Output