

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The course covers important and advance elements of C and C plus plus programming language. This course provides the student with the skills required to design, code, and test and execute programs of simple to intermediate complexity. It includes: Program, Library, Commands, Declaration, Integer, Type, Function, Variables, Inputs, Printf, Validity, Check
Typology: Exercises
1 / 3
This page cannot be seen from the preview
Don't miss anything!
/In the very first step of program,the library will be included which will contain necessary information of commands i used in the program./
#include<stdio.h>
/second step is the declaration ,that main function of the program is integer type function/
int main()
/the program is written in the middle brackets{}/
{
/it is the declaration that variables are of which type/
float a,b,p,q; int m,c,s,d,w,x;
/topic of program/
printf("CHECKING OF VALIDITY OF INPUTS ACCORDING TO GIVEN CRITERIA\n\n\n");
/by this printf command user will be able to know that he has to enter input here/
printf("give two numbers\na="); scanf("%f",&a ); printf("b="); scanf("%f",&b);
/in the following steps the validity of inputs will be checked/ /*in this first step program will check that either inputs are integers or not */
c=a;
if(a-c!=0) { printf("a is not a valid input as a is not an integer\n"); }
m=b;
if(b-m!=0) { printf("b is not a valid input as b is not an nteger\n"); }
if (a<1 || a>100) { printf("a is not a valid input as a is not between 1 and 100\n");
if (b<1 || b>100) { printf("b is not a valid input as b is not between 1 and hundred\n"); }
/in this step program will check that either inputs are divisible by each other or not/
q=a/b; p=b/a; w=q; x=p;
if(q/w==1 || p/x==1) { printf("inputs a and b are not valid as they are divisible by each other\n"); } /*in this step program will check that either difference of inputs are 1 or not */
if (a-b==1 || b-a==1) { printf("inputs are not valid as their difference is 1\n"); }
s=a+b;
/in this step program will check that either sum of inputs is exceeding 100 or not/
if(s>100) { printf("inputs a and b are not valid as sum of inputs is exceeding 100\n"); }
/if all of the following conditions are true simultaneously then inputs will be valid/
if ((a/c==1)&&(b/m==1)&&(a>1 && a<100)&&(b>1 && b<100)&&(q/w!=1 || p/x!=1)&& (a-b!=1 && b-a!=1)&&(s<101))
/here the output for the valid inputs will be displayed/
{ printf("inputs are valid as they fulfill following criteria\n1-both a and b are integers\n2-Both inputs are between 1 and 100\n3-Both inputs are not divisible by each other\n4-Difference of inputs is not 1\n5-the sum of inputs is not exceeding 100\n"); }