Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

03/07/2020 Problem solving through Programming In C - Course

(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)

reviewer4@nptel.iitm.ac.in 

NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » Problem solving through Programming In C

(course)

Announcements (announcements)

About the Course (https://swayam.gov.in/nd1_noc20_cs06/preview) Ask a Question (forum)

Progress (student/home) Mentor (student/mentor)

Week-05 Problem-03
Course Due on 2020-03-05, 23:59 IST
outline
Write a C program to check whether the given number(N) can be expressed as
Power of Two (2) or not.
How does an For example 8 can be expressed as 2^3.
NPTEL online
course work?
Sample Test Cases
Input Output
Week 0
Test Case 65
6572 cannot be expressed as power of 2.
Week 1 1 72

Week 2 Test Case 10 1024 is a number that can be expressed as po


2 24 wer of 2.
Week 3
Test Case 8 is a number that can be expressed as power
Week 4 8
3 of 2.

Week 5 Test Case


46 46 cannot be expressed as power of 2.
4
Lecture 21: For
Statement
The due date for submitting this assignment has passed.
(Contd.) (unit?
As per our records you have not submitted this assignment.
unit=6&lesson=35)
Sample solutions (Provided by instructor)
Lecture 22: 1 #include <stdio.h>
Example of If- 2 int main()
Else (unit?
3 {
4 int N;
unit=6&lesson=36) 5 scanf("%d",&N); /* The value of N is taken from the test case data
6
Lecture 23 : 7 /* Complete the code.
Example of 8 Use the printf statements as below

https://onlinecourses.nptel.ac.in/noc20_cs06/progassignment?name=120 1/3
03/07/2020 Problem solving through Programming In C - Course

Loops (unit? 9 printf("%d is a number that can be expressed as power of 2.",N);


unit=6&lesson=37) 10 printf("%d cannot be expressed as power of 2.",N);
11 */
12
Lecture 24 : 13 int temp, flag;
Example of 14 temp=N;
Loops (Contd.) 15 flag=0;
16
(unit? 17 while(temp!=1)
unit=6&lesson=38) 18 {
19 if(temp%2!=0){
Lecture 25 : 20 flag=1;
21 break;
Example of 22 }
Loops 23 temp=temp/2;
(Contd.), Use 24 }
25
of FOR Loops 26 if(flag==0)
(unit? 27 printf("%d is a number that can be expressed as power of 2.",N)
unit=6&lesson=39) 28 else
29 printf("%d cannot be expressed as power of 2.",N);
Quiz :
30 }
31
Assignment 5
(assessment?
name=104)

Week-05
Problem-01
(/noc20_cs06/progassignment?
name=118)

Week-05
Problem-02
(/noc20_cs06/progassignment?
name=119)

Week-05
Problem-03
(/noc20_cs06/progassignment?
name=120)

Week-05
Program-04
(/noc20_cs06/progassignment?
name=121)

Week-05
Program-05
(/noc20_cs06/progassignment?
name=122)

Feedback For
Week 5 (unit?
unit=6&lesson=130)

Week 6

Week 7

Week 8

Week 9

Week 10

https://onlinecourses.nptel.ac.in/noc20_cs06/progassignment?name=120 2/3
03/07/2020 Problem solving through Programming In C - Course

Week 11

Week 12

DOWNLOAD
VIDEOS

Assignment
Solution

https://onlinecourses.nptel.ac.in/noc20_cs06/progassignment?name=120 3/3

You might also like