Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Pointer Part 3-Computer Fundamentals-Lab Codes, Exercises of Computer Fundamentals

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: Standard, Input, Variable, Declaration, Integer, Loop, Check, Condition, Divisible, Break, Statement

Typology: Exercises

2011/2012

Uploaded on 07/31/2012

karthik
karthik 🇮🇳

4.6

(17)

100 documents

1 / 1

Toggle sidebar

Related documents


Partial preview of the text

Download Pointer Part 3-Computer Fundamentals-Lab Codes and more Exercises Computer Fundamentals in PDF only on Docsity! /* * prime2.c * * Created on: Nov 13, 2010 * Author: mohsan */ #include <stdio.h> // standard input out int main() // main entry point into the program { // start of main int p,i,input; // variable declaration scanf("%d",&input); // user input integer // first loop that will check each number less then equal to user // input integer for(i=1;i<=input;i++) { // second loop check each number is divisible by any of its smaller // number or not. for(p=1;p<=i;p++) { // prime number condition check that is number should only // be divisible by itself and one if(i%p==0 && i!=p && p!=1) { // if number is divisible by any other number then // its not prime number printf("%d is not a prime \n",i); // exit inner loop using break statement break; } if(p==i) { // if we have check above condition for all numbers // smaller then give number then its a prime number printf("%d is a prime \n",i); } } // end of inner for loop } // end of outer for loop } docsity.com
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved