Concept explainers
What is the output of the following?
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (3rd Edition)
C++ How to Program (10th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Database Concepts (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
- sum = 0; for (int i = 1; i< n; i = sum++ || 2*i)arrow_forwardfor ( int i =0; i <= n; i++ ) { System.out.println( "The number is " + i ); if ( i == n ) i = i – n; } identify the type of error in the above code and give brief explanation to itarrow_forward#include int main() { } int a, b, c, i=0; for (c=0; c < 7; C++) { } for(b 0; b < c; b++) { } for(a 0; a < b; a++) { } return 0; shown above? printf("%d\n", i++); ) What is the final value of i in the codearrow_forward
- int n = 1; int k - 2; int r = n; if (k < n) { r - karrow_forward#include <stdio.h>int main(){int i, j, k=0;for (i=1; i<3; i++){for (j=1; j<3; j++){k = i+j;printf("Value of k is %d\n" ,k);}}printf("Value of k is %d\n",2*k);return 0;} how do you modify this code so k only prints even numbersarrow_forward1. a. Are Count and sum the same? yes or no, why? { int sum = 0; for ( int count = 0; count < 10; count++ ) { System.out.print( count + " " ); sum = sum+count; } } b. { int sum = 0; for ( int count = 0; count < 10; count++ ) { System.out.print( count + " " ); sum = sum+count; } System.out.println("\nAfter the loop count is: " + count ); } c. What is printed, why? class FindIt { private int sum; public FindIt( int sum ) { this.sum = sum; } public void increment( int inc ) { sum = sum + inc; System.out.println("FindIt sum: " + sum ); } } public class MainClass { public static void main ( String[] args) { int sum = 99; FindIt findObj = new FindIt( 34 ); findObj.increment( 6 ); System.out.println("sum: " + sum ); } }arrow_forward
- (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by initializing 10 counters to 0, and then generate a large number of pseudorandom integers between 0 and 9. Each time a 0 occurs, increment the variable you have designated as the zero counter; when a 1 occurs, increment the counter variable that’s keeping count of the 1s that occur; and so on. Finally, display the number of 0s, 1s, 2s, and so on that occurred and the percentage of the time they occurred.arrow_forward#include int main(void) { int a[3][3] = {1,3,5,7,9}; int i,j,sum=0; for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) sum += a[i-i][j-j]; %3D printf("%d\n",sum); return 0; }arrow_forward#include <stdio.h> #include <stdlib.h> double f(double x){ return x*x; } double reimannSums(double f(double), double a, double b, int n, double deltax) double sum=0.0, x; int i; printf("n = %d\n",nvoidvoid); for (i=0;i<n;i++){ x= ( (a+i*deltax)+a+(i+1)*deltax))/2; printf("x = %lf\n,x"); sum=sum + f(x); } return sum = (sum * deltax); double integ(double a, double b, double deltax) { double result; int n; n = (b - a) / deltax; return reimannSums(f, a, b, n, deltax); } int main(int argc, char * argv[]) { int a = atoi(argv[1]); int b = atoi(argv[2]); double deltax = atof(argv[3]); printf("result= %lf",integ(a, b, deltax)); } CAN YOU PLEASE CHECK MY WORK I GOT BUILD FAILED ERROR C LANGUAGE I NEED ANSWER IN 30 MIN THANKS<3arrow_forward
- ***VERY URGENT, THIS IS AN ARDUINO QUESTION. PLEASE ANSWER FAST, I WILL UPVOTE YOUR ANSWER**** //variables int YELLOW = 3; int RED = 4; int DELAY_YELLOW = 1000; int DELAY_RED = 1000; // basic functions void setup() { pinMode(YELLOW, OUTPUT); pinMode(RED, OUTPUT); } void loop() { yellow_light(); delay(DELAY_YELLOW); red_light(); delay(DELAY_RED); } void yellow_light() { digitalWrite(YELLOW, HIGH); digitalWrite(RED, LOW); } void red_light() { digitalWrite(YELLOW, LOW); digitalWrite(RED, HIGH); } Modify the program so that while the button is held down the LEDs alternate as fast as possible. When the button is not pressed the LED state freezes. This creates a random color programarrow_forwardwrite the output. for (i=1;i<=5;i++) { if(i==2) continue; printf(“%d”,i); }arrow_forward#include<stdio.h> #include<conio.h> int mutex=1,full=0,empty=1,x=0; main() { int n; void producer(); void consumer(); int wait(int); int(signal); printf("\n1. Producer \n2. Consumer \n,3. Exit \n"); while(1) { printf("\n Enter the choice:"); scanf("%d", &n); switch(n); { case-1: if((mutex==1)&&(empty!=0)) producer(); else printf("Nuffer is full"); break; case-2: if((mutex==1)&&(full!=0)) consumer(); else print("Buffer is empty"); break; case-3: exit(0); break; } } } int wait(int s) {return(--s); } int signal(int s) { return(++s); } void producer() { mutex = wait(mutex); full = signal(full); empty=wait(empty); x++; printf("\n Producer produces the item %d",x); mutex= signal(mutex); } void consume() { mutex = wait(mutex); full = wait(full); empty = signal(empty); printf("\n Consumer consumes item %d",x); x--; mutex = signal(mutex); } CONVERT THIS C LANGUAGE CODE IN BASH SCRIPT THANKYOUarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr