0% found this document useful (0 votes)
32 views3 pages

Noc20-Cs06 Week 05 Assignment 04

This document is from an online NPTEL course on problem solving through programming in C. It provides instructions for an assignment to write a C program to check if a given number can be expressed as a power of two. Sample test cases and solutions are provided. The due date for submitting this assignment has passed.

Uploaded by

Suhas Hatti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views3 pages

Noc20-Cs06 Week 05 Assignment 04

This document is from an online NPTEL course on problem solving through programming in C. It provides instructions for an assignment to write a C program to check if a given number can be expressed as a power of two. Sample test cases and solutions are provided. The due date for submitting this assignment has passed.

Uploaded by

Suhas Hatti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy